home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / DATETIME.SWG / 0010_DAYOF-YR.PAS.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  892b  |  35 lines

  1. { RN> Does someone have a Procedure I can use to give me a String
  2.  RN> containing the "day number" ? ie: if today is day number
  3.  RN> 323, the Function/Procedure would contain that.
  4. }
  5.  Uses Crt;
  6.  
  7.  Var today,
  8.      year, month, day : Word;
  9.  
  10.  Const
  11.   TDays       : Array[Boolean,0..12] of Word =
  12.                 ((0,31,59,90,120,151,181,212,243,273,304,334,365),
  13.                 (0,31,60,91,121,152,182,213,244,274,305,335,366));
  14.  
  15. Function DayofTheYear(yr,mth,d : Word): Word;
  16.   { valid For all years 1901 to 2078                                  }
  17.   Var
  18.     temp  : Word;
  19.     lyr   : Boolean;
  20.   begin
  21.     lyr   := (yr mod 4 = 0);
  22.     temp  := TDays[lyr][mth-1];
  23.     inc(temp,d);
  24.     DayofTheYear := temp;
  25.   end;  { PackedDate }
  26.  
  27. begin
  28.   ClrScr;
  29.   year := 92;
  30.   month := 12;
  31.   day := 31;
  32.   today := DayofTheYear(year,month,day);
  33.   Writeln(today);
  34.   readln;
  35. end.